#ifndef RECEIVE_H
#define RECEIVE_H

#include <QObject>
#include <QThread>
#include "serialport.h"

class ReceiveThread : public QThread
{
    Q_OBJECT
public:
    ReceiveThread(SerialPortInterface::SerialPort *serialport, QObject *parent = 0);
    ~ReceiveThread() {}
protected:
    void run();
signals:
    void CharReceived(char);
private:
    SerialPortInterface::SerialPort *serialport;
};

enum DisplayType {
    ascii,
    hex,
    asciihex,
    uint8,
    int8,
    binary
};

class Receive : public QObject
{
    Q_OBJECT
public:
    explicit Receive(SerialPortInterface::SerialPort *serialport, QObject *parent = 0);
    ~Receive();

signals:
    void CharReceived(QString);
public slots:
    void CharReceived(char ch);

    void Displayascii();
    void Displayhex();
    void Displayasciihex();
    void Displayuint8();
    void Displayint8();
    void Displaybinary();
private:
    SerialPortInterface::SerialPort *serialport;
    DisplayType displaytype;
    ReceiveThread *receivethread;
};

#endif // RECEIVE_H
